require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
const webhookRouter = require('./routes/webhooks');

const app = express();

// Middleware
app.use(bodyParser.json());

// Routes
app.use('/webhooks', webhookRouter);

// Start server
const PORT = process.env.PORT;
if (!PORT) {
  console.error('PORT environment variable is required');
  process.exit(1);
}
app.listen(PORT, () => {
  console.log(`Webhook service running on port ${PORT}`);
});
